package operation;

import book.Book;
import book.BookList;

/**
 * @program: 11.19
 * @description:
 * @author: 李鑫月
 * @create: 2021-11-19 17:15
 **/
public class BorrowOperation implements IOperation {
    public void work(BookList bookList){
        System.out.println("借阅图书");
        System.out.println("请输入你要借阅的书：");
        String name=scanner.nextLine();
        int size=bookList.getUsedSize();
        for (int i = 0; i < size; i++) {
            Book book=bookList.getPos(i);
            if (book.getName().equals(name)){
                book.setBorrowed(true);
                System.out.println("借阅成功");
                return;
            }
        }
        System.out.println("没有这本书");
    }
}
